<?php
/* -----------------------------------------------------------------------------------------
   $Id: xtc_db_error.inc.php,v 1.1 2010/09/08 10:55:03 akausch Exp $   

   XT-Commerce - community made shopping
   http://www.xt-commerce.com

   Copyright (c) 2003 XT-Commerce
   -----------------------------------------------------------------------------------------
   based on: 
   (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
   (c) 2002-2003 osCommerce(database.php,v 1.19 2003/03/22); www.oscommerce.com 
   (c) 2003	 nextcommerce (xtc_db_error.inc.php,v 1.4 2003/08/19); www.nextcommerce.org 

   Released under the GNU General Public License 
   ---------------------------------------------------------------------------------------*/
  function xtc_db_error($errno, $errstr, $errfile, $errline) {
    switch ($errno) {
    case E_USER_ERROR:
        if ($errstr == "(SQL)"){
            // handling an sql error
            if ($_SESSION['customers_status']['customers_status_id'] == 0) {
				echo "<b>SQL Fehler</b> [$errno] " . SQLMESSAGE . "<br /><br />\n\n";
				echo "<b>Query:</b> " . SQLQUERY . "<br /><br />\n\n";
				echo "Beim Aufruf der Datei <em>" . SQLERRORFILE . "</em> ";
				echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br /><br />\n\n";
			}
            echo "<b>Die Abfrage wurde abgebrochen, kontaktieren Sie den Administrator...</b><br /><br />\n\n";
        } else {
			if ($_SESSION['customers_status']['customers_status_id'] == 0) {
				echo "<b>My ERROR</b> [$errno] $errstr<br />\n";
				echo "  Fatal error on line $errline in file $errfile";
				echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
			}
            echo "<b>Die Abfrage wurde abgebrochen, kontaktieren Sie den Administrator...</b><br />\n";
        }
        exit(1);
        break;

    case E_USER_WARNING:
    case E_USER_NOTICE:
    }
    /* Don't execute PHP internal error handler */
    return true;
  }


function sqlerrorhandler($ERROR, $QUERY, $PHPFILE, $LINE) {
    define("SQLQUERY", $QUERY);
    define("SQLMESSAGE", $ERROR);
    define("SQLERRORLINE", $LINE);
    define("SQLERRORFILE", $PHPFILE);
    trigger_error("(SQL)", E_USER_ERROR);
}

set_error_handler("xtc_db_error");
?>